<?php
/**
 * 获取催签记录详细
 * User: Administrator
 * Date: 2018\8\8 0008
 * Time: 9:54
 */

namespace app\lib\Order\OrderSign;


use app\model\OrderSignRecordModel;

class GetOrderSignRecord
{
    protected $signId;
    protected $table;
    public function __construct($signId)
    {
        $this->signId = $signId;
    }

    protected function getTable(){
        if(empty($this->table)){
            $this->table = new OrderSignRecordModel();
        }
        return $this->table;
    }

    protected function getValueField($field){
        $model =  $this->getTable();
        $map   =  [$model->_id=>$this->signId];
        return $model->where($map)->value($field);
    }

    /**
     * 指定期数是否签收
     * @return bool
     */
    public function IsSign(){
        $model =  $this->getTable();
        $field =  $model->_status;
        $result =  $this->getValueField($field);
        return $result==1?true:false;
    }

    /**
     * 指定期数是否没签收
     * @return bool
     */
    public function IsNoSign(){
        $model =  $this->getTable();
        $field =  $model->_status;
        $result =  $this->getValueField($field);
        return $result==0?true:false;
    }

    /**
     * 签收记录是否存在
     * @return bool
     */
    public function IsExit(){
        $model =  $this->getTable();
        $field =  $model->_id;
        $result =  $this->getValueField($field);
        return empty($result)?false:true;
    }

}